package kdroid.namespace;

import android.app.Activity;
import android.app.AlertDialog;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;
import android.widget.Toast;
//import android.widget.ImageView;
//import android.widget.TextView;

import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface;

//import android.content.DialogInterface;

public class CustomerdiaglogActivity extends Activity {
    /** Called when the activity is first created. */
	final CharSequence[] grades={"A","A-","B","B-","C","C-","D","D-"};
	    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //button action
        final Button switchbutton =  (Button) findViewById(R.id.button1);
        switchbutton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
			//INIT DIALOG
				//assemble dialog
				AlertDialog.Builder builder = new AlertDialog.Builder(CustomerdiaglogActivity.this);
				builder.setTitle("Pick Your Grade");
				builder.setSingleChoiceItems(grades, -1, new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int item) {
						// TODO Auto-generated method stub
						Toast.makeText(getApplicationContext(), grades[item], Toast.LENGTH_SHORT).show();
						
					}
				});
				//Add button to close dialog
				builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.cancel();
					}
				});
				//create and show dialog
				AlertDialog alert = builder.create();
				alert.show();
			}
		});
    }

}